<?php
namespace app\tripapi\controller;
use app\tripapi\model\ApprovalProces;
use think\Controller;
use think\Request;
class Apply extends ApiBaseController
{
    public function __construct()
    {
        parent::__construct();
        $this->ApprovalProcess = new ApprovalProces();
    }

    /*
     * 首页
     */
    public function index()
    {
        //获取部门审批流列表
        return $this->fetch();
    }

    /*
     * 添加
     */
    public function add()
    {
        return $this->fetch();
    }

    /*
     * 编辑
     */
    public function edit()
    {
        $id = $_GET['id'];
        $result = $this->ApprovalProcess->GetDetailById($id);
        $this->assign('detail', $result);
        return $this->fetch();
    }

    /*
     * Ajax 获取列表
     */
    public function AjaxGetList()
    {
        $result = $this->ApprovalProcess->GetList();
        $json = array("status" => 200, "msg" => "获取成功", "data" => $result);
        return json_api($json);
    }

    /*
     * 保存
     */
    public function save()
    {
        $result = $this->ApprovalProcess->CustomerSave($this->params);
        if ($result) {
            $json = array("status" => 200, "msg" => "保存成功", "data" => $result);
            return json_api($json);
        } else {
            $json = array("status" => 500, "msg" => "保存失败", "data" => $result);
            return json_api($json);
        }
    }

    /*
     * 更新
     */
    public function update()
    {
        $result = $this->ApprovalProcess->CustomerUpdate($this->params);
        if ($result) {
            $json = array("status" => 200, "msg" => "更新成功", "data" => $result);
            return json_api($json);
        } else {
            $json = array("status" => 500, "msg" => "更新失败", "data" => $result);
            return json_api($json);
        }
    }
}
?>